<input type="hidden" th:value="#{plant.dialog.add.title}" id="addTitle">
<input type="hidden" th:value="#{plant.dialog.edit.title}" id="editTitle">
<input type="hidden" th:value="#{common.dialog.add}" id="addTitle2">
<input type="hidden" th:value="#{common.dialog.edit}" id="editTitle2">
<div id="main" class="pd14 vany_authority">
    <div class="vany_treeTable pd14">
        <!--面包屑-->
        <div class="pb10" id="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item :to="{ path: '/' }" th:text="#{breadcrumb.procurement}">Procurement Community</el-breadcrumb-item>
                <el-breadcrumb-item th:text="#{breadcrumb.plant}">Procurement Community</el-breadcrumb-item>
            </el-breadcrumb>
            <i-favorite></i-favorite>
        </div>
        <div>
            <el-tabs type="card" @tab-click="changeTab">
                <el-tab-pane th:label="#{plant.tab.list}"></el-tab-pane>
                <el-tab-pane th:label="#{plant.tab.assignment}"></el-tab-pane>
            </el-tabs>
        </div>
        <div v-if="tabType==0">
            <el-form :inline="true">
                <el-form-item>
                    <el-input
                            th:placeholder="#{plant.list.search}"
                            v-model="search.key"
                            @keyup.enter.native="getData"
                            clearable>
                    </el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="getData" th:text="#{common.search}">search</el-button>
                </el-form-item>
            </el-form>
            <el-row>
                <el-col>
                    <el-button type="primary" icon="el-icon-plus" @click="addPlant" th:text="#{common.add}">Add</el-button>
                    <el-button type="primary" icon="el-icon-share" @click="exportPlant" th:text="#{common.export}">Export</el-button>
                </el-col>
            </el-row>
            <el-table :data="tableData" v-loading="listLoading" :height="tableHeight">
                <el-table-column label="" prop="id">
                    <template scope="scope">
                        <img src="templates/img/edit.png" @click="editPlant(scope.row)"/>
                        <img src="templates/img/delete.png" @click="deletePlant(scope.row)"/>
                    </template>
                </el-table-column>
                <el-table-column th:label="#{plant.table.code}" prop="plantCode"></el-table-column>
                <el-table-column th:label="#{plant.table.name.en}" prop="englishName"></el-table-column>
                <el-table-column th:label="#{plant.table.name.cn}" prop="chineseName"></el-table-column>
                <el-table-column th:label="#{plant.table.cluster}" prop="plantCluster"></el-table-column>
            </el-table>
            <el-pagination
                    @size-change=""
                    @current-change=""
                    :current-page="search.current"
                    :page-size="search.size"
                    layout="total, prev, pager, next"
                    :total="total">
            </el-pagination>
        </div>
        <el-dialog :title="dialogTitle" :visible.sync="addVisible">
            <el-form :model="form" ref="form" label-width="200px">
                <el-form-item th:label="#{plant.table.cluster}">
                    <el-select v-model="form.plantCluster" th:placeholder="#{common.hint.select}">
                        <el-option v-for="item in clusters" :label="item.text" :value="item.text" :key="item.text"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item th:label="#{plant.table.code}">
                    <el-input v-model="form.plantCode" :disabled="codeDisabled"></el-input>
                </el-form-item>
                <el-form-item th:label="#{plant.table.name.en}">
                    <el-input v-model="form.englishName"></el-input>
                </el-form-item>
                <el-form-item th:label="#{plant.table.name.cn}">
                    <el-input v-model="form.chineseName"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitForm" th:text="#{common.submit}">确 定</el-button>
                <el-button @click="addVisible = false" th:text="#{common.cancel}">取 消</el-button>
            </span>
        </el-dialog>

        <div v-if="tabType==1">
            <el-form :inline="true">
               <el-form-item th:label="#{plant.name}">
                   <el-input clearable v-model="tab2.search.plant"></el-input>
               </el-form-item>
               <el-form-item th:label="#{plant.procurement}">
                   <el-input clearable v-model="tab2.search.user"></el-input>
               </el-form-item>
               <el-form-item th:label="#{plant.status}">
                   <el-select v-model="tab2.search.status">
                       <el-option
                               v-for="item in tab2.statusArr"
                               :key="item.value"
                               :label="item.label"
                               :value="item.value">
                       </el-option>
                   </el-select>
               </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="getUserData" th:text="#{common.search}">search</el-button>
                </el-form-item>
            </el-form>
            <el-row>
                <el-col>
                    <el-button type="primary" icon="el-icon-plus" @click="addPlantUser" th:text="#{common.add}">Add</el-button>
                    <el-button type="primary" icon="el-icon-share" @click="exportPlantUser" th:text="#{common.export}">Export</el-button>
                </el-col>
            </el-row>
            <el-table :data="tab2.tableData" v-loading="tab2.listLoading" :height="tableHeight">
                <el-table-column label="" prop="id">
                    <template scope="scope">
                        <img src="templates/img/edit.png" @click="editPlantUser(scope.row)"/>
                        <img src="templates/img/delete.png" @click="deletePlantUser(scope.row)"/>
                    </template>
                </el-table-column>
                <el-table-column th:label="#{plant.table.code}" prop="plantCode"></el-table-column>
                <el-table-column th:label="#{plant.assignment.table.name}" prop="plantName"></el-table-column>
                <el-table-column th:label="#{plant.assignment.ppm}" prop="procurementManagerName"></el-table-column>
                <el-table-column th:label="#{plant.assignment.pp}" prop="procurementUserName"></el-table-column>
                <el-table-column th:label="#{plant.status}">
                    <template scope="scope">
                        {{scope.row.id==null?'No':'Yes'}}
                    </template>
                </el-table-column>
                <el-table-column th:label="#{common.update.user}" prop="modifyUserName"></el-table-column>
                <el-table-column th:label="#{common.update.date}" prop="modifyTime"></el-table-column>
            </el-table>
            <el-pagination
                    @size-change=""
                    @current-change=""
                    :current-page="tab2.search.current"
                    :page-size="tab2.search.size"
                    layout="total, prev, pager, next"
                    :total="tab2.total">
            </el-pagination>
        </div>
        <el-dialog :title="dialogTitle" :visible.sync="tab2.addVisible">
            <el-form :model="tab2.form" label-width="200px">
                <el-form-item th:label="#{plant.name}">
                    <el-select v-model="tab2.form.plantCode" th:placeholder="#{common.hint.select}" @change="changeCode" :disabled="tab2.codeDisabled">
                        <el-option v-for="item in tab2.plants" :label="item.plantCode" :value="item.plantCode" :key="item.plantCode"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item th:label="#{plant.assignment.ppm}">
                    <el-select v-model="tab2.form.procurementManager" th:placeholder="#{common.hint.select}" :disabled="tab2.ppmDisabled">
                        <el-option v-for="item in tab2.ppms" :label="item.chineseName" :value="item.id" :key="item.id">
                            <span style="float: left">{{ item.chineseName }}</span>
                            <span style="float: right">{{ item.sapStaffNo }}</span>
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item th:label="#{plant.assignment.pp}">
                    <el-select v-model="tab2.form.procurementUser" th:placeholder="#{common.hint.select}">
                        <el-option v-for="item in tab2.pps" :label="item.chineseName" :value="item.id" :key="item.id">
                            <span style="float: left">{{ item.chineseName }}</span>
                            <span style="float: right">{{ item.sapStaffNo }}</span>
                        </el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitUserForm" th:text="#{common.submit}">确 定</el-button>
                <el-button @click="tab2.addVisible = false" th:text="#{common.cancel}">取 消</el-button>
            </span>
        </el-dialog>
    </div>
</div>
<script type="text/javascript" src="templates/data/js/plant.js?ts=new Date().getTime()"></script>